package com.insight.common.mq.stream;

import lombok.Getter;
import com.insight.common.constant.CacheConstant;
import com.insight.common.mq.MessageType;

/**
 * @author JinPengDong
 * @date 2023/10/10
 */
@Getter
public enum Streams {

    /**
     * 导入导出通知
     */
    GENERATE_DOWNLOAD_INFO(new RedisMqStream("generateDownloadInfo", MessageType.unicast)),
    /**
     * 消息通知
     */
    NOTICE(new RedisMqStream("notice", MessageType.unicast)),
    /**
     * 收集器接收到数据
     */
    ON_DATA(new RedisMqStream("on_data", MessageType.unicast)),
    /**
     * 状态改变
     */
    STATUS_CHANGE(new RedisMqStream("statusChange", MessageType.unicast)),
    /**
     * 规则匹配
     */
    MATCH_RULE_MODEL(new RedisMqStream("matchRuleModel", MessageType.unicast)),
    /**
     * 规则匹配结果
     */
    MATCH_RULE_RESULT(new RedisMqStream("matchRuleResult", MessageType.unicast)),
    /**
     * 产生告警
     */
    PRODUCE_ALARM(new RedisMqStream("produceAlarm", MessageType.unicast)),
    /**
     * 恢复告警
     */
    RECOVERY_ALARM(new RedisMqStream("recoveryAlarm", MessageType.unicast)),
    /**
     * 产生告警
     */
    DEVICE_SCORE(new RedisMqStream("deviceScore", MessageType.unicast)),
    /**
     * 发送告警内容
     */
    SEND_CONTENT(new RedisMqStream("sendContent", MessageType.unicast)),
    /**
     * 构建流程
     */
    CHAIN_BUILD(new RedisMqStream("chainBuild", MessageType.publicize)),
    /**
     * 销毁流程
     */
    REMOVE_CHAIN(new RedisMqStream("removeChain", MessageType.publicize)),
    /**
     * udp心跳
     */
    UDP_HEARTBEAT(new RedisMqStream("udpHeartBeat", MessageType.unicast)),
    /**
     * 发送矩阵端口状态
     */
    PORT_STATUS(new RedisMqStream("portStatus", MessageType.unicast)),
    /**
     * 更新缓存物模型
     */
    UPDATE_METADATA(new RedisMqStream("updateMetadata", MessageType.publicize)),
    /**
     * 启动设备监控
     * deviceConnParamSave
     */
    DEVICE_MONITORING_START(new RedisMqStream("deviceMonitoringStart", MessageType.publicize)),
    /**
     * 关闭设备监控
     * deviceConnParamDelete
     */
    DEVICE_MONITORING_STOP(new RedisMqStream("deviceMonitoringStop", MessageType.publicize)),
    /**
     * 改变设备监控
     * deviceConnParamChange
     */
    DEVICE_MONITORING_CHANGE(new RedisMqStream("deviceMonitoringChange", MessageType.publicize)),
    /**
     * 配置字典变更
     */
    CONFIGURE_DICT_CHANGE(new RedisMqStream("configureDictChange", MessageType.publicize)),
    /**
     * 配置字典刷新
     */
    CONFIGURE_DICT_REFRESH(new RedisMqStream("configureDictRefresh", MessageType.publicize)),
    /**
     * 数据上报管理上级信息刷新
     */
    DATA_REPORT_MANAGE_REFRESH(new RedisMqStream("dataReportManageRefresh", MessageType.publicize)),
    /**
     * 业务可用性监控配置变更
     */
    BUSINESS_AVAILABILITY_CHANGE(new RedisMqStream("businessAvailabilityChange", MessageType.publicize)),
    /**
     * SSH、Telnet执行备份还原命令
     */
    SSH_TELNET_EXECUTE(new RedisMqStream("sshTelnetExecute", MessageType.publicize)),
    /**
     * SSH、Telnet定时执行备份还原命令 开启定时任务
     */
    SSH_TELNET_TIMED_EXECUTE_ENABLE(new RedisMqStream("sshTelnetTimedExecuteEnable", MessageType.publicize)),
    /**
     * SSH、Telnet定时执行备份还原命令 暂停任务
     */
    SSH_TELNET_TIMED_EXECUTE_STOP(new RedisMqStream("sshTelnetTimedExecuteStop", MessageType.publicize)),
    /**
     * SSH、Telnet定时执行备份还原命令 重置任务
     */
    SSH_TELNET_TIMED_EXECUTE_RESET(new RedisMqStream("sshTelnetTimedExecuteReset", MessageType.publicize)),
    /**
     * SSH、Telnet定时执行备份还原命令 开启单次任务
     */
    SSH_TELNET_TIMED_EXECUTE_ONESHOT(new RedisMqStream("sshTelnetTimedExecuteOneShot", MessageType.publicize)),
    /**
     * SSH、Telnet定时执行备份任务完毕后，通知平台转存文件至Minio
     */
    SSH_TELNET_FILE_TO_MINIO(new RedisMqStream("sshTelnetFileToMinio", MessageType.unicast)),

    /**
     * Prometheus Server删除监控目标
     */
    DELETE_MONITOR_TARGET(new RedisMqStream("deleteMonitorTarget", MessageType.unicast)),
    /**
     * 第三方监控对接拉取任务管理
     */
    ABUTMENT_PULL_JOB_CONTROL(new RedisMqStream("abutmentPullJobControl", MessageType.publicize)),

    /**
     * 南大通用数据库定时执行备份还原命令 暂停任务
     */
    GBASE_JOB_CONTROL(new RedisMqStream("gbaseJobControl", MessageType.unicast)),

    /**
     * 确认告警主题
     */
    ALARM_CONFIRM(new RedisMqStream("alarmConfirm", MessageType.unicast)),
    /**
     * websocket广播消息
     */
    WEBSOCKET_PUBLICIZE(new RedisMqStream("websocketPublicize", MessageType.publicize)),
    /**
     * 保留值:currentKey
     * 以当前的消费者名称做key
     */
    WEBSOCKET_CURRENT(new RedisMqStream("websocket:" + CacheConstant.CURRENT_KEY, MessageType.publicize)),
    /**
     * 自动控制脚本执行器
     */
    AUTO_CONTROL_SCRIPT_EXECUTE(new RedisMqStream("autoControlScriptExecute", MessageType.publicize)),
    ;

    final RedisMqStream value;

    Streams(RedisMqStream value) {
        this.value = value;
    }

    public static MessageType findMessageType(String streamKey) {
        for (Streams value : Streams.values()) {
            final RedisMqStream redisMqStream = value.getValue();
            if (redisMqStream.getName().equals(streamKey)) {
                return redisMqStream.getMessageType();
            }
        }
        return MessageType.publicize;
    }
}
